package nl.hr.minor.mobilelife.j1213.jlr.words;

import java.util.Arrays;
import java.util.List;

public class Score 
{
	private static List<Integer> SCORE_TABLE = Arrays.asList(
			1, 3, 3, 3, 1, // a - e
			4, 2, 4, 1, 8, // f - j
			5, 1, 3, 1, 1, // k - o
			3, 10, 1, 1, 1, // n - r
			1, 1, 1, 4, 4, // s - w
			8, 4, 10); // x - z

	private static List<Character> ALPHABET = Arrays.asList('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');

	public static int calculateScore(String word) {

		int wordLength = word.length();
		int score = 0;
		char[] userWord = word.toCharArray();

		for(int i = 0; i < wordLength; i++){
			score += SCORE_TABLE.get(ALPHABET.indexOf(userWord[i]));
		}

		score *= wordLength;

		return score;
	}
}
